<?php
/*
*
* -------------------------------------------------------
* CLASSNAME:        newsletterlog
* GENERATION DATE:  11.04.2013
* CLASS FILE:       D:\wamp\www\webpros\webpros_sites\webpros\module-generator/generated-classes/class.newsletterlog.inc.php
* FOR MYSQL TABLE:  newsletterlog
* FOR MYSQL DB:     modulegenerator
* -------------------------------------------------------
* -------------------------------------------------------
*
*/

class newsletterlog {
/**
*   @desc Variable Declaration with default value
*/
	private $_id;   // KEY ATTR. WITH AUTOINCREMENT
     private $_did;  
     private $_eid;  	 private $_subject;  
     private $_senddate;  
     
/**
*   @desc   CONSTRUCTOR METHOD
*/
	function __construct() {
		global $DBOBJ;
		$this->_obj = $DBOBJ;
		$this->_id = null; 
		$this->_did = null; 
		$this->_eid = null; 		$this->_subject = null; 		$this->_senddate = null; 
	}

/**
*   @desc   DECONSTRUCTOR METHOD
*/
	function __destruct() {
		unset($this->_obj);
	}

/**
*   @desc   GETTER METHODS
*/

     public function getid() {
     	return $this->_id;
     }
     
     public function getdid() {
     	return $this->_did;
     }
     
     public function geteid() {
     	return $this->_eid;
     }	 	 public function getsubject() {     	return $this->_subject;     }	 	 
     
     public function getsenddate() {
     	return $this->_senddate;
     }
     
/**
*   @desc   SETTER METHODS
*/

     public function setid($id) {
     	 $this->_id =  $id;
     }
     
     public function setdid($did) {
     	 $this->_did =  $did;
     }
     
     public function seteid($eid) {
     	 $this->_eid =  $eid;
     }	 	 public function setsubject($subject) {     	 $this->_subject =  $subject;     }	 	 
     
     public function setsenddate($senddate) {
     	 $this->_senddate =  $senddate;
     }
     
/**
*   @desc   SELECT METHOD / LOAD
*/

	public function select($id) {
		 $sql =  "SELECT * FROM `newsletterlog` WHERE `id` = '". $id ."' ";
		 $row =  $this->_obj->select($sql); 

		 if (count($row) > 0) {
			 $this->_id = $row[0]['id'];
     		 $this->_did = $row[0]['did'];
     		 $this->_eid = $row[0]['eid'];			 $this->_subject = $row[0]['subject'];			 
     		 $this->_senddate = $row[0]['senddate'];
     			 return $row[0];
		}else {
			 return;
		}
	}
/**
*   @desc   set All
*/
	 public function setAll($dataArray = array()) {
		 if (count($dataArray) <= 0) {
			return;
		}

		foreach ($dataArray as $key => $value) {
			$classKey = '_' . $key;
			$this->$classKey = $value;
		}
	}

/**
*   @desc   get All
*/

	 public function getAll($FORMAT = 'ARRAY') {
		$dataArray = new stdClass();
		$dataArray->id = $this->getid();
     	$dataArray->did = $this->getdid();
     	$dataArray->eid = $this->geteid();				$dataArray->subject = $this->getsubject();		
     	$dataArray->senddate = $this->getsenddate();
     	if ($FORMAT == 'ARRAY') {
			return (array) $dataArray;
		}
		return $dataArray;
	}
/**
*   @desc   COUNT
*/

	public function getCountnewsletterlog() {
		 $sql = "SELECT count(*) as cnt  FROM `newsletterlog`";
		 $result = $this->_obj->select($sql);
		 return $result['0']['cnt'];
	}

/**
*   @desc   DELETE
*/
	public function delete($id) {
		 $sql = "DELETE FROM `newsletterlog` WHERE `id` = '". $id ."'";
		 $result = $this->_obj->sql_query($sql);
	}

/**
*   @desc   INSERT
*/
	public function insert() {
		 $this->id = ""; // clear key for autoincrement		
		 $sql = "INSERT INTO `newsletterlog` ( `id`,`did`,`eid`,`subject`,`senddate` ) VALUES ( NULL,'".$this->_did."','".$this->_eid."','".$this->_subject."','".$this->_senddate."' )";
		 $result = $this->_obj->insert($sql);
		 return $result;
	}

/**
*   @desc   UPDATE
*/
	public function update($id) {
		 $sql = " UPDATE `newsletterlog` SET  `id` = '".$this->_id."' , `did` = '".$this->_did."' , `eid` = '".$this->_eid."', `subject` = '".$this->_subject."' , `senddate` = '".$this->_senddate."'  WHERE `id` =   '".$id."' ";
		 $result = $this->_obj->sql_query($sql);
	}
	public function getAllNewsletterlogList($params = "*", $where = "", $orderby = "id", $limit = "") {
		$orderby = "ORDER BY " . $orderby;
		$sql = "SELECT " . $params . " FROM `newsletterlog` a  " . $where . " " . $orderby . " " . $limit;
		$row = $this->_obj->select($sql);
		if ($row) {
			return $row;
		}
		return array();
	}
	
	public function performListAction($action = "", $ids = "''") {
		switch ($action) {
			case "delete":
				$sql = "DELETE FROM `newsletterlog` WHERE `id` IN (" . $ids . ")";
			break;
			default:
				$sql = "";
		}
		if ($sql == "") {
			return false;
		}
		$result = $this->_obj->sql_query($sql);
		return true;
    }

} 
?>